package com.jay.aigcoj.service.impl;

import com.jay.aigcoj.bot.ds.DSApi;
import com.jay.aigcoj.model.dto.chat.ChatRequest;
import com.jay.aigcoj.model.dto.chat.ChatResponse;
import com.jay.aigcoj.service.AIChatService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Service
public class AIChatServiceImpl implements AIChatService {

    @Resource
    private DSApi dsApi;

    @Override
    public ChatResponse chat(ChatRequest chatRequest, HttpServletRequest request) {
        try {
            String response = dsApi.sendDeepseekChat(chatRequest.getMessage());
            ChatResponse chatResponse = new ChatResponse();
            chatResponse.setContent(response);
            return chatResponse;
        } catch (Exception e) {
            throw new RuntimeException("AI聊天服务异常", e);
        }
    }
}